package system;



public class Edge {

	public ActionPoint getP1() {
		return p1;
	}


	public ActionPoint getP2() {
		return p2;
	}

	boolean waterway = true;
	ActionPoint p1;
	ActionPoint p2;
	Player p;
	
	public void assign(Player p){
		this.p = p;
	}
	
	public Edge(ActionPoint p1, ActionPoint p2){
		this.p1 = p1;
		this.p2 = p2;
	}
	
	public void setStreet(){
		waterway = false;
	}
	
	public boolean hasPoint(ActionPoint p){
		return p.equals(p1)||p.equals(p2);
	}
	
	@Override
	public boolean equals(Object o){
		if (!( o instanceof Edge))
			return false;
		else
		{
			return (p1.equals(((Edge) o).getP1())&& p2.equals(((Edge) o).getP2()))||(p1.equals(((Edge) o).getP2())&& p2.equals(((Edge) o).getP1()));
		}
	}
	
	
	public boolean isWaterWay(){
//		for (Tile t : p1.getTiles()) {
//			for (Tile t2 : p2.getTiles()) {
//				if (t.equals(t2) && t.getTile() != Tiles.WATER)
//					return false;
//			}
//		}
//		return true;
		return waterway;
	}
	
	
	@Override
	public String toString(){
		return "[(" + p1.x + "," + p1.y + ")" + "(" + p2.x + "," + p2.y + ")]";
	}
	
	public static void main(String args[]){
	Edge e1 = new Edge(new ActionPoint(1, 5), new ActionPoint(2, 3));
	Edge e2 = new Edge(new ActionPoint(1, 5), new ActionPoint(2, 3));
	Edge e3 = new Edge(new ActionPoint(2, 3), new ActionPoint(1, 5));
	Edge e4 = new Edge(new ActionPoint(2, 3), new ActionPoint(1, 4));
	System.out.println(e1.equals(e2));
	System.out.println(e1.equals(e3));
	System.out.println(e3.equals(e2));
	System.out.println(!e1.equals(e4));
	System.out.println(!e2.equals(e4));
		
	}


	public Player getOwner() {
		// TODO Auto-generated method stub
		return p;
	}
}
